package easy

func MaximumCount1(nums []int) int {
	pos, neg := 0, 0
	for _, num := range nums {
		if num > 0 {
			pos++
		} else if num < 0 {
			neg++
		}
	}
	return max(pos, neg)
}

func MaximumCount(nums []int) int {
	pos1 := lowerBound(nums, 0)
	pos2 := lowerBound(nums, 1)
	return max(pos1, len(nums)-pos2)
}

func lowerBound(nums []int, val int) int {
	l, r := 0, len(nums)
	for l < r {
		m := (l + r) / 2
		if nums[m] >= val {
			r = m
		} else {
			l = m + 1
		}
	}
	return l
}
